package com.example.demo.controller;

import java.util.Map;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
public class DemoController {

	@RequestMapping("/")
	public String index() {
		return "index!";
	}
	@RequestMapping("/test")
	public String test() {
		return "test!";
	}
	
	@RequestMapping("/search")
	public String search(@PathVariable(value = "category") String category,@PathVariable(value = "brand") String brand) {
		
	    System.out.println("category="+category+" brand="+brand);
		return "test!";
	}
	
	@RequestMapping("/hello")
    public ModelAndView hello(){
        ModelAndView mv=new ModelAndView("hello");//模板文件的名称，不需要指定后缀
        mv.addObject("key","hello freemaker");
        return mv;
    }
	@RequestMapping("/hello2")
    public String hello2(Map<String, Object> map){
		map.put("key", "hello freemaker2");
        return "hello";
    }
	
	
	@RequestMapping("/websocket")
    public ModelAndView websocket(){
        ModelAndView mv=new ModelAndView("websocket");//模板文件的名称，不需要指定后缀
        return mv;
    }
}
